#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  03-fileaccess.sh
# Version	:  1.0
# Date		:  2025/02/06
# Author	:  yaoxiyao
# Email		:  yaoxiyao@kylinos.com.cn
# Function	:  GN-WJXT_005文件的访问
# Out		:
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="GN-WJXT_005文件的访问"

## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB() {
    return $TPASS
}

## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB() {
    return $TPASS
}

## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB() {
    testcase_1
    return $TPASS
}

## TODO ： GN-WJXT_005文件的访问
testcase_1() {
    local filesystem_src="../src/file-property.c"
    gcc ${filesystem_src}
    CommRetParse_LTFLIB "gcc ${filesystem_src}"
    mv a.out ${TmpTestDir_LTFLIB}
    CommRetParse_LTFLIB "mv a.out ${TmpTestDir_LTFLIB}"
    timeout 3s ${TmpTestDir_LTFLIB}/a.out
    if [ "$?" -eq 124 ]; then
        OutputRet_LTFLIB ${TPASS}
        TestRetParse_LTFLIB "执行${TmpTestDir_LTFLIB}/a.out会一直显示文件内容"
    else
        OutputRet_LTFLIB ${TFAIL}
        TestRetParse_LTFLIB "执行${TmpTestDir_LTFLIB}/a.out不会一直显示文件内容"
    fi
    timeout 3s stdbuf -o0 ${TmpTestDir_LTFLIB}/a.out | grep "PID"
    CommRetParse_LTFLIB "timeout 3s stdbuf -o0 ${TmpTestDir_LTFLIB}/a.out |grep \"PID\""
}
#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
